<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #app1 {
            width: 5rem; /* 在414的设计图，一半的宽度的div 那么就这么换算，207/41.4 = 5rem 41是下面js转换了分成10分的视口总宽*/
            height: 100px;
            background-color: red;
        }

        #app2 {
            margin: 20px 0;
            width: 50vw;
            height: 100px;
            background-color: yellow;
        }
    </style>
</head>

<body>
    <div id="app1"></div>
    <div id="app2"></div>
</body>
<script>
    var winW = document.documentElement.clientWidth;
    var htmlFont = winW / 10;
    document.getElementsByTagName('html')[0].style.fontSize = htmlFont + 'px';

</script>

</html>